import 'package:lai_zhan/common/config/ExportConfig.dart';
import 'package:lai_zhan/common/model/courseResult/course_result.dart';
import 'package:lai_zhan/common/util/NavigatorUtil.dart';

class CourseItem extends StatelessWidget {

  CourseResult course;
  VoidCallback onClick;
  int _doing;
  Color _color;


  CourseItem({this.course, this.onClick});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    //_doing = course.limit - course.left;
    //_color = course.left<course.limit*0.1?Colors.red:Colors.green;
    return new GestureDetector(
      child: new Card(
        elevation: 4,
        shape: new RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(10.0))),
        child: new Stack(
          children: <Widget>[
            new FadeInImage.assetNetwork(placeholder: Config.DEFALUT_COURSE_IMAGE, image: '',fit: BoxFit.cover,width: AppSize.ScreenWidth,
              height: AppSize.ScreenWidth/16*6,
            ),
            new Container(width: AppSize.ScreenWidth,height: AppSize.ScreenWidth/16*6,
              color: Color(AppColors.grey800),),
            new Positioned(top: 15,
              child: new Container(
                height: AppSize.getRealHeight(20),
                width: AppSize.getRealWidth(50),
                decoration: BoxDecoration(
                  color: Color(AppColors.orangeA700),
                  borderRadius: BorderRadius.only(topRight: Radius.circular(6),bottomRight: Radius.circular(6))
                ),
                child: new Center(child: new Text('可预约',style: AppConstant.smallTextWhite,),)
              ),),
            new Positioned(child: new Column(
              mainAxisAlignment: MainAxisAlignment.end,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                new Text('标题·小荣',style: AppConstant.largeTextWhiteBold,),
                new Padding(padding: EdgeInsets.all(1)),
                new Text('时间段/周期/地点',style: AppConstant.middleTextWhiteBold,),
                new Padding(padding: EdgeInsets.all(2)),
                new Container(height: AppSize.getRealHeight(20),
                decoration: BoxDecoration(color: Color(AppColors.grey900),borderRadius: BorderRadius.circular(15.0)),
                child: new Row(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    new Padding(padding: EdgeInsets.all(3)),
                    new Icon(AppIcon.MONEY,size: 13,color: Color(AppColors.white),),
                    new SizedBox(child: new Text('100/时',style: AppConstant.smallTextWhite,),width: AppSize.getRealWidth(50),),
                    new Icon(AppIcon.SUBSCRIBER,size: 15,color: Color(AppColors.white),),
                    new Text('11/20',style: AppConstant.smallTextWhite,),
                    new Padding(padding: EdgeInsets.all(3)),
                  ],
                ),
              )],
            ),
              width: AppSize.ScreenWidth,
              bottom: 5,left: 10,),
          ],
        )
      ),
      onTap: (){
        NavigatorUtil.goCoursePage(context,course);
      },
    );
  }
}